<?php
class MasterController extends PlatformController
{
	/**
	 * 显示站长信息
	 */
	public function indexAction()
	{
		$master=Factory::M('MasterModel');
		$masterInfo=$master->getMasterInfo();
		$this->assign('masterInfo',$masterInfo);
		$this->display('index.html');
	}
	/**
	 * 修改动作
	 */
	public function editAction()
	{
		$masterInfo=array();
		$masterInfo['nickname']=$this->escapeData($_POST['nickname']);
		$masterInfo['job']=$this->escapeData($_POST['job']);
		$masterInfo['home']=$this->escapeData($_POST['home']);
		$masterInfo['email']=$this->escapeData($_POST['email']);
		$masterInfo['tel']=$this->escapeData($_POST['tel']);

		
		//判断数据合法性
		if(empty($masterInfo['nickname']) || empty($masterInfo['job']) || empty($masterInfo['home']) || empty($masterInfo['email']) ||
			empty($masterInfo['tel']))
		{
			$this->jump('index.php?p=Back&c=Master&a=index',':(信息不完整!');
		}
		$master=Factory::M('MasterModel');
		$result=$master->updateMasterInfo($masterInfo);
		if($result)
		{
			$this->jump('index.php?p=Back&c=Master&a=index','更新成功');
		}
		else
		{
			$this->jump('index.php?p=Back&c=Master&a=index','未知错误,更新失败');
		}
	}
}